<?
include("./_common.php");
if(!$GCODE || $GCODE=="")
{
	echo("<script>alert('상품코드가 없습니다.');history.back(-1);</script>");
}
else
{
	include("$g4[path]/_head.php");

	$shop = get_shop();
	put_hit($GCODE);

	$goods = get_goods($GCODE);

	$category_info = get_category($goods[c_code]);

?>
<link rel="stylesheet" href="<?=$g4['path']?>/shop/style.css" type="text/css">
<script language="javascript" src="<?=$g4['path']?>/shop/shop.js"></script>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<form name="goods">
<input type="hidden" name="gcode" value="<?=$goods[g_code]?>">
	<tr>
		<td>
			<table cellpadding="0" cellspacing="0" border="0" width="100%">
				<tr>
					<td width="300"><?=$goods[img2]?></td>
					<td width="30"></td>
					<td valign="top">
						<table cellpadding="5" cellspacing="0" border="0" width="100%" style="border:solid 1px #D7D7D7">
							<tr>
								<td width="100" class="blog_index">상품명</td>
								<td>
								<b><?=$goods[g_name]?></b><br>
								<span style="color:orange"><?=$goods[g_info]?></span>
								</td>
							</tr>
							<tr><td colspan="2" height="1" bgcolor="#D7D7D7"></td></tr>
							<tr>
								<td class="blog_index">제조/판매원</td>
								<td><?=$goods[g_create]?></td>
							</tr>
							<tr><td colspan="2" height="1" bgcolor="#D7D7D7"></td></tr>
							<tr>
								<td class="blog_index">생산지</td>
								<td><?=$goods[g_nation]?></td>
							</tr>
							<tr><td colspan="2" height="1" bgcolor="#D7D7D7"></td></tr>
							<tr>
								<td class="blog_index">배송비</td>
								<td><?=$goods[tranc]?></td>
							</tr>
							<tr><td colspan="2" height="1" bgcolor="#D7D7D7"></td></tr>
							<tr>
								<td class="blog_index">재고</td>
								<td><?=$goods[cnt]?></td>
							</tr>
							<tr><td colspan="2" height="1" bgcolor="#D7D7D7"></td></tr>
							<?if(trim($goods[g_option])!=""){?>
							<tr>
								<td class="blog_index">상품옵션</td>
								<td>
								<select name="g_option">
									<option value="">옵션을 선택하세요.</option>
									<?
									$tmp_option = explode("[RECORD]",$goods[g_option]);
									for($i=1;$i<=count($tmp_option);$i++)
									{
										$tmpOptVal = explode("[FIELD]",$tmp_option[($i-1)]);
									?>
									<option value="<?=$i?>"><?=$tmpOptVal[0]?>(+<?=number_format($tmpOptVal[1])?>원)</option>
									<?}?>
								</select>
								</td>
							</tr>
							<tr><td colspan="2" height="1" bgcolor="#D7D7D7"></td></tr>
							<?}?>
							<tr>
								<td class="blog_index">판매가</td>
								<td><span style="color:#990000"><?=number_format($goods[g_price])?>원</span></td>
							</tr>
							<tr><td colspan="2" height="1" bgcolor="#D7D7D7"></td></tr>
							<tr>
								<td class="blog_index">조회/판매수</td>
								<td><?=number_format($goods[g_hit])?>회 / <?=number_format($goods[g_sale])?>EA</td>
							</tr>
							<tr><td colspan="2" height="1" bgcolor="#D7D7D7"></td></tr>
						</table>
						<table cellpadding="0" cellspacing="0" border="0" width="100%">
							<tr>
								<td colspan="2" height="50" align="center">
								<button class="cart_btn1" style="margin-right:3px" onclick="buyCheck('direct')">바로구매</button>
								<button class="cart_btn1" onclick="buyCheck('addcart')">장바구니</button>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr height="10"><td></td></tr>
	<tr height="30">
		<td class="blog_index">상품상세설명</td>
	</tr>
	<tr>
		<td style="padding:10 0 0 0"><?=$goods[content]?></td>
	</tr>
	<tr height="10"><td></td></tr>
	<tr height="30">
		<td class="blog_index">배송정보</td>
	</tr>
	<tr>
		<td style="padding:10 0 0 0"><?=stripslashes($shop[tranc_info]);?></td>
	</tr>
</form>
</table>
<script>
function buyCheck(TYPE)
{
	var frm = document.goods;
	var MOD = "add";
	var GCODE = frm.gcode.value;
	var CNT = "";
	var GOPTION = frm.g_option.value;
	if(GCODE == "")
	{
		alert("제품이 삭제되었거나 잘못된 상품입니다.");
		history.back(-1);
	}
	<?if(trim($goods[g_option])!=""){?>
	else if(frm.g_option.value == "")
	{
		alert("상품옵션을 선택하세요.");
		frm.g_option.focus();
	}
	<?}?>
	else
	{
		if(TYPE == "direct")
		{
			new ajax("cart_update.php?MOD="+MOD+"&GCODE="+GCODE+"&CNT="+CNT+"&GOPTION="+GOPTION,DirectBuyResult);
		}
		else
		{
			new ajax("cart_update.php?MOD="+MOD+"&GCODE="+GCODE+"&CNT="+CNT+"&GOPTION="+GOPTION,CartResult);
		}
	}
}
</script>
<?
	include("$g4[path]/_tail.php");
}
?>